{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f7d385c8",
   "metadata": {},
   "source": [
    "# 上周回顾        \n",
    "\n",
    "## 1.字典的三种创建方式        \n",
    "\n",
    "## 2.字典性质                                                      \n",
    "> 1.无序的                      \n",
    "> 2.key唯一                     \n",
    "> 3.key不可变                    \n",
    "\n",
    "# 本周学习内容\n",
    "\n",
    "## 1.字典循环便利\n",
    "\n",
    "## 2.字典的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "472e1499",
   "metadata": {},
   "outputs": [],
   "source": [
    "info = {\n",
    "    \"stu2001\":\"ziqi\",\n",
    "    \"stu2002\":\"xxxy\",\n",
    "    \"stu2003\":\"wwwk\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "738b93e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu2001': 'ziqi', 'stu2002': 'xxxy', 'stu2003': 'wwwk'}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1638b5d5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu2001\n",
      "stu2002\n",
      "stu2003\n"
     ]
    }
   ],
   "source": [
    "# A-1\n",
    "# i 只是key的值 指内容没有真正意义上获取到字典的完整信息\n",
    "\n",
    "for i in info:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1bdb97fa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu2001 ziqi\n",
      "stu2002 xxxy\n",
      "stu2003 wwwk\n"
     ]
    }
   ],
   "source": [
    "# A-2\n",
    "# 1.字典循环 如何循环key:value 作为item输出\n",
    "for k,v in info.items():\n",
    "    print(k,v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "79a1a071",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践1：学号的k 去掉stu 然后输出新的字典\n",
    "new_info ={}\n",
    "\n",
    "for k,v in info.items():\n",
    "    # 字典的新增\n",
    "    new_info[k[3:]] = v"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f0c62ea6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'2001': 'ziqi', '2002': 'xxxy', '2003': 'wwwk'}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "346924f1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
